Page({
  data: {
    oaCount:0,
  },
  onLoad() { 
    this.getOaCount();
  },
  onShow(){
   
  },
  getOaCount(){
    let that = this;
    this.request({
      url: 'https://wh.risenoa.com:23100/oameeting/public/meeting/getOaCount.do',
      // 调用成功的回调函数
    }).then(function (res) {
        if (res.data || res.data.data) {
          that.setData({
            oaCount: +res.data.data
          })
          //  my.alert({ content: that.data.oaCount});
          my.tg.playTTS({
            text: "您当前的待办事项还剩" +that.data.oaCount + "条",
            openMic: true
          });
        } else {
          my.alert({ content: res.data.messages[0] });
        }
      }
    )
  },
  request(config) {
    return new Promise((resolve,reject)=>{
      my.request({
        ...config,
        data: {
        },
        dataType: 'json', // 期望返回的数据格式，默认json，支持json，text，base64
        method: 'GET',
        success(res){
          resolve(res)
        },
        // 调用失败的回调函数
        fail: function (res) {
          my.alert({ content: '调用失败' });
           reject(res)
        },
      });
    })
  },
  onNeed(dish) {
    this.getOaCount()
  },
  pagechage(dish){
    let needStrArr = ["待办", "代办", "带办", "带半", "待半"];
    let newmeeting=['新建会议','信件','心间','兴建',"新建"];
    let strArr = ["首", "首页", "守夜", "授业", "受业"];
    if(newmeeting.includes(dish)){
      this.toPage("../meeting/meeting")
    }else if (strArr.includes(dish)) {
      this.toPage("../index/index")
    } else {
      my.tg.playTTS({ text: '您好，您可以说：打开首页', openMic: true });
    }
  },
  toPage(pageUrl) {
    my.redirectTo({
      url: pageUrl
    })
  },
});
